import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int sum = in.nextInt();
        StringBuffer stringbuffer = new StringBuffer();
        while (in.hasNext()) { // 注意 while 处理多个 case
            stringbuffer.append(in.next());
        }
        char[] operate = stringbuffer.toString().toCharArray();
        int left = 1;
        int right = 4;
        int n = 4;
        if(sum<4) {
            n = sum;
        }
        // 光标
        int count = left;
        for(int i = 0;i<operate.length;i++) {
            if('U' == operate[i]) {
                //处理第一页第一行
                if(count == 1) {
                    //窗口改到最后一页
                    right = sum;
                    left = right - (n - 1);
                    count = right;
                }else if (count == left) {
                    //处理非第一页的第一行up
                    count--;
                    left--;
                    right--;
                }else {
                    //不翻页
                    count--;
                }
            }else {
                if (count == sum) {
                    //处理最后一页最后一行
                    left = 1;
                    right = left + (n - 1);
                    count = 1;
                }else if(count == right) {
                    //处理非最后一页最后一行
                    count++;
                    left++;
                    right++;
                }else {
                    count++;
                }
            }
        }
        while(left<=right) {
            System.out.print(left + " ");
            left++;
        }
        System.out.printf("\n");
        System.out.println(count);
        
    }
}